Title : redocneXk version 1.10
Author : Samuel Austin (AKA Tril on driverheaven.net)
Contact : samaust@hotmail.com or PM me on driverheaven
Date : 27 march 2008
-----------------------------------------------------------------------------
The avcodec library is licensed under the LGPL.  It is dynamically loaded at 
runtime.  See the included lgpl.txt file for a copy of the LGPL license.

The library was compiled from the source.

You can get it from the FFmpeg CVS repository.  It is hosted by the MPlayer 
project at http://www.mplayerhq.hu/ .

avcodec.dll was compiled using ./configure --enable-shared --enable-memalign-hack 
--disable-debug --disable-ffplay --disable-ffserver --disable-audio-oss 
--disable-decoders --disable-static --disable-demuxer=gxf

ASIO is a trademark of Steinberg Media Technologies GmbH.

redocneXk is in no way affiliated, associated or connected with Creative 
Technology Inc.

Thanks to Insomnia Visions.  I use some code from their tutorial on WaveOut.

Thanks to hector santos, I use his source code from the article 'Flexible 
Command Line Arguments Class' posted on the website 'The Code Project'.

Thanks to lallous, I use his source code from the article 'Global hotkeys made easy' posted on the website 'The Code Project'.

Special thanks to Russ on DriverHeaven.net for answering programming questions
and suggesting improvements.
-----------------------------------------------------------------------------

What it does :
--------------
It encodes to AC3 what you send it by using ASIO.  ASIO is used to transfer 
audio from the sound card to the cpu.  The cpu encodes the sound to AC3 and
send it out of the computer by using the sound card digital passthru.  You 
can easily do this to every sound played in windows with this program.


Switches
--------

There are currently six switches supported.

-d : driver number. (Default = 0)
That's the number assigned to the ASIO driver.  Use this switch without any
parameters to see the available drivers.

-m : mode. (Default = 0)
This is the mode selection.  There are three modes and four choices of
parameters available.  This sets which inputs will be used.
0 = auto-detection
1 = kX drivers mode
2 = Audigy/Audigy2 on Creative drivers mode
3 = X-Fi on Creative drivers mode

Here are the ASIO inputs used for the different modes.  The indexes start at 0.
kX drivers mode :
FL  = asio 0
FR  = asio 1
RL  = asio 2
RR  = asio 3
C   = asio 4
LFE = asio 5
	
Audigy/Audigy2 on Creative drivers mode :
FL  = asio 4 + asio 12
FR  = asio 5 + asio 13
RL  = asio 6 + asio 12 + asio 10
RR  = asio 7 + asio asio 13 + asio 11
C   = asio 8
LFE = asio 9

X-Fi on Creative drivers mode :
FL  = asio 2 + asio 8
FR  = asio 3 + asio 9
RL  = asio 4 + asio 8
RR  = asio 5 + asio 9
C   = asio 6
LFE = asio 7

-b : bitrate. (Default = 640000)
Between 32000 and 640000.  The lowest bitrates probably won't work because they 
are too small for six channels.  The program chooses the next supported bitrate
if a non-supported one is entered.

-r : renderer. (Default = 0)
Used to choose the audio renderer.  Usually, one is faster than the other.  My 
tests showed that WaveOut was sligtly faster in this program.
0 = WaveOut
1 = DirectSound

-o : output device. (Default = Windows default audio device)
Used to choose to which audio device the encoded AC3 stream encapsulated into 
SPDIF is sent.  It is Useful if the sound card that you want to use for 
passthru is not the Windows default audio device.  Use this switch without any
parameters to see the available audio devices.

-p : priority. (Default = 4)
No parameters = See the available choices
0 = Idle
1 = Below normal
2 = Normal
3 = Above normal
4 = High
5 = Realtime

-l : latency. (Default = 1)
This is a switch that controls how much the audio buffer gets fulled before the
encoding starts.  Its parameter is the number of ASIO buffers that get put in
memory before starting the encoding.  It has an impact on latency so that's why
it is nicknamed latency.  You should usually leave this at 1.  If the audio is
skipping heavily and changing the ASIO latency does not solve the problem, you
can try to increase this.  It has been tested to help on an X-Fi. The range is
from 1 to 4.

-h : hideConsole. (Default = 57 [for 9 key])
To hide the console window, hold control + alt + the selected key.  For available values, see below.

-s : showConsole. (Default = 48 [for 0 key])
To show the console window, hold control + alt + the selected key.  The available values are what is called the virtual key codes.  You need to enter the decimal number for the key you wish to use.  You can find them in the net.  For example, here :
http://www.tronan.com/macromachine/scripthelp/VK.htm
http://www.indigorose.com/webhelp/ams50/Program_Reference/Misc/Virtual_Key_Codes.htm

-v : Volume (Default = 100)
Use a number from 0 to 100 to adjust the volume.  A volume of 100 is the loudest.
Not available in the kX drivers.  Use six Vol plugins in the DSP.


You don't have to use the switches if the default settings suit your needs.
The next two commands produce the same result
redocneXk.exe
redocneXk.exe -d 0 -m 0 -b 640000 -r 0 -p 4 -l 1 -h 57 -s 48 -v 100


kX drivers specific information :
---------------------------------
In the DSP, connect the first 6 pins of Surrounder+ to the pins asio0 to asio5
on epilog and activate passthru in the mixer (check 'Digital Output Only' and
select "SPDIF 0" for 'Toggle AC-3 Passthru mode'). Then double-click
redocneXk.exe.


X-Fi on Creative drivers specific information :
-----------------------------------------------
- Reduce the "What you Hear" (WUH) volume in the Creative console or the WAVE volume of the sound mixer in Windows until you don't hear any hard clipping.
- Change the recording source to "What you Hear" (WUH) in the Creative console.


Script
------

You can start and stop redocneXk with a script.  I included a sample VBScript to show how to do it.  The sample does :
Start redocneXk
Wait 5 seconds
Start calc.exe
Wait until calc.exe is closed
Stop redocneXk
Display redocneXk text output from the console

One way to use this could be to make a script to start redocneXk before starting a game and automatically stop it after the game closes.


Changelog
---------

version 1.10
- Made redocneXk compatible with a script command to stop it.
- Made and included a sample script

version 1.09
- Fixed -o switch.

version 1.08
- Fixed DirectSound output bug.

version 1.07
- Fixed -b and -r switches.

version 1.06
- Fixed a memory leak that happened when freeing the memory used by the encoder.
- Fixed a bug related to the ASIO out buffers.
- Added the -h and -s switches.
- Improved the conversion from 24 bit to 16 bit.  The volume needs less to be reduced.

version 1.05
- Changed the title of the window to the program's name.
- Changed the code that manages the switches.  This makes it easier and faster 
  to add new switches.
- Added -m switch.
- Added -p switch.
- Added -l switch.
- Removed -f switch.
- Removed -i switch.
- Removed a few memory leaks.
- Added a condition that stops the execution, instead of crashing, if not 
  enough ASIO inputs are available.
- Added X-Fi support.
- Added basic 24 bits support (fast conversion from 24 bit to 16 bit, 
  the WAVE volume of the sound mixer in Windows needs to be reduced or else 
  there will be hard clipping)
- Removed the display of the number of available ASIO outputs and of the output
  latency because they are not needed.
- Removed all the bitrates that were too low for encoding six channels.
- Changed a little the way the program handled the encoding.
  It seems like Realtime priority is no longer absolutely necessary but it is
  still used because there is still some stuttering without it.
- Added basic autodetection of the ASIO Driver.  For now, what it does is select 
  the second ASIO driver if you don't use the -d switch and if the first driver 
  is ASIO4ALL.  The reason is that it only supports 2 ASIO inputs.
- Added a message to display if ASIO driver initialization fails.
- Moved from ffmpeg CVS release 20041113 to the SVN release of 20061205.  There
  is a new dll called avutil-49.dll because of changes in the code of ffmpeg.

version 1.04
- Added switch -f.

version 1.03
- Modified switch -d.  You can now Use this switch without any
  parameters to see the available drivers.
- Added a small delay when starting.  This fixes a problem some people had where
  redocneXk produced clicks and pops as soon as it was started.

version 1.02
- Slight modification to the DirectSound code.
- Changed an incorrect error message.
- Added the -o switch.
- Decided not to compile and not provide SSE/SSE2 executables because they are 
  not faster.  That's because only the main program and not the encoder was 
  compiled using SSE/SSE2 optimizations.

version 1.01
- Modified the ringbuffer algorithm and the buffer size and removed one buffer 
  copy action.
- Moved from ffmpeg CVS release 20041113 to the CVS release of 20051121.  
  This requires a recompile because the include files changed.
- Removed a conditional test in the playback function.
- Moved from Microsoft Visual Studio 6.0 to Microsoft Visual Studio .NET 2003.
- Compiled for SSE and SSE2.  Not tested because my cpu does not support them.